package com.hqd.ch03.v28.spel.context;

import com.hqd.ch03.v28.spel.EvaluationContext;
import com.hqd.ch03.v28.spel.PropertyAccessor;

import java.util.ArrayList;
import java.util.List;

/**
 * 运算是上下文默认实现
 */
public class StandardEvaluationContext implements EvaluationContext {
    private Object rootObj;
    private List<PropertyAccessor> propertyAccessors = new ArrayList<>();

    public StandardEvaluationContext() {

    }

    public StandardEvaluationContext(Object rootObj) {
        this.rootObj = rootObj;
    }

    public void addPropertyAccessor(PropertyAccessor accessor) {
        this.propertyAccessors.add(accessor);
    }

    @Override
    public Object getRootObj() {
        return rootObj;
    }

    @Override
    public List<PropertyAccessor> getPropertyAccessors() {
        return propertyAccessors;
    }
}
